package moonstruckdrops.page;

import moonstruckdrops.dao.ProfileDao;
import moonstruckdrops.dto.ProfileDto;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextArea;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.PropertyModel;

import com.google.appengine.api.datastore.Text;

public class ProfilePage extends WebPage{
	String inputBlogTitle="";
	String inputBlogComent="";
	String inputBlogAuthor="";
	String inputBlogAuthorProfile="";
	public ProfilePage(){
		
		/*
		 * ここにプロフィールが存在するかどうかをチェックする
		 * 無ければ空をあれば中身を
		 */
		
		
		final TextField<String> BlogTitle =new TextField<String>("BlogTitle",new PropertyModel<String>(this,"inputBlogTitle"));
		final TextField<String> BlogComent = new TextField<String>("BlogComent",new PropertyModel<String>(this,"inputBlogComent"));
		final TextField<String> BlogAuthor = new TextField<String>("BlogAuthor",new PropertyModel<String>(this,"inputBlogAuthor"));
		final TextArea<String> BlogAuthorProfile = new TextArea<String>("BlogAuthorProfile",new PropertyModel<String>(this,"inputBlogAuthorProfile"));
		Form<Void> ProfileForm =new Form<Void>("ProfileForm"){
			private static final long serialVersionUID = 1L;
			public void onSubmit(){
				ProfileDto dto = new ProfileDto(BlogTitle.getInput(),BlogComent.getInput(),BlogAuthor.getInput(),new Text(BlogAuthorProfile.getInput()));
				ProfileDao dao = new ProfileDao();
				dao.SaveProfile(dto);
				setResponsePage(BlogMainPage.class);
			}
		};
		add(ProfileForm);
		ProfileForm.add(BlogTitle);
		ProfileForm.add(BlogComent);
		ProfileForm.add(BlogAuthor);
		ProfileForm.add(BlogAuthorProfile);
	}
}